.. currentmodule:: brian .. _example-frompapers-computing with neural synchrony-coincidence detection and synchrony_Fig5E_precision_reliability: Example: Fig5E_precision_reliability (frompapers/computing with neural synchrony/coincidence detection and synchrony) ===================================================================================================================== Brette R (2012). Computing with neural synchrony. PLoS Comp Biol. 8(6): e1002561. doi:10.1371/journal.pcbi.1002561 ------------------------------------------------------------------------------------------------------------------ Figure 5E. (very long simulation) Caption (Fig 5E). Precision and reliability of spike timing as a function of SNR. Simulations are run in parallel on all cores but one. :: from brian import * import multiprocessing def autocor(PSTH,N=None,T=20*ms,bin=None): ''' Autocorrelogram of PSTH, to calculate a shuffled autocorrelogram N = number of spike trains T = temporal window bin = PSTH bin The baseline is not subtracted. Returns times,SAC ''' if bin is None: bin=defaultclock.dt n=len(PSTH) p=int(T/bin) SAC=zeros(p) if N is None: SAC[0]=mean(PSTH*PSTH) else: # correction to exclude self-coincidences PSTHnoself=clip(PSTH-1./(bin*N),0,Inf) SAC[0]=mean(PSTH*PSTHnoself)*N/(N-1.) SAC[1:]=[mean(PSTH[:-i]*PSTH[i:]) for i in range(1,p)] SAC=hstack((SAC[::-1],SAC[1:])) return (arange(len(SAC))-len(SAC)/2)*bin,SAC def halfwidth(x): ''' Returns half-width of function given by x in bin numbers. This is used to calculate the precision (left panel). ''' M,n=max(x),argmax(x) return find(x[n:]